var rootPath=null;

$(document).ready(function(){  
	rootPath=getRootPath();
	changebackimg();
	order();
});  
	// $("#select_id").append("<option value='Value'>Text</option>"); 




 function order(){
 	var idd = window.sessionStorage.getItem("id");
 	
 $.ajax({
		    url : rootPath+"/getVoucher",
		    type : "get",
		    dataType : "json",
		    data : {
		    	studentId:idd
		    },
		    cache : true,
		    async : true,
		    success : function(requestJson) {
		    	var requestStudentArray=requestJson.extend.Orders;
		    	//alert(requestStudentArray.id+""+requestStudentArray.examineeId+""
		    	//+requestStudentArray.cardId+""+requestStudentArray.name+""+requestStudentArray.school+""
		    	//+requestStudentArray.major+""+requestStudentArray.price+""+requestStudentArray.startTime);
		    	document.getElementById("dingdanbianhao").innerHTML=requestStudentArray.id;
		    	document.getElementById("fukuanshijian").innerHTML=fmtDate(requestStudentArray.startTime);
		    	document.getElementById("xingming").innerHTML=requestStudentArray.name;
		    	document.getElementById("shenfenzhenghao").innerHTML=requestStudentArray.cardId;
		    	document.getElementById("kaoshenghao").innerHTML=requestStudentArray.examineeId;
		    	document.getElementById("fushiyuanxiao").innerHTML=requestStudentArray.school;
		    	document.getElementById("fushizhuanye").innerHTML=requestStudentArray.major;
		    	document.getElementById("jine").innerHTML="￥"+requestStudentArray.price/100;
		    	var orderid=requestStudentArray.id;
		    	var payTime=fmtDate(requestStudentArray.startTime);
		    	var name=requestStudentArray.name;
		    	var cardId=requestStudentArray.cardId;
		    	var examineeId=requestStudentArray.examineeId;
		    	var school=requestStudentArray.school;
		    	var major=requestStudentArray.major;
		    	var price=requestStudentArray.price;
//		    	alert(requestStudentArray);
//		    	two(requestStudentArray);
//				var qrcode = new QRCode(document.getElementById("qrcode"), {
//				        width: 250, //设置宽高
//				        height: 250
////				        colorLight:'#00000000'
//				    });
//				var massage=Base.encode(orderid+'/'+payTime+'/'+name+'/'+examineeId+'/'+cardId+'/'+school+'/'+major+'/'+price);
//			    qrcode.makeCode(massage);
		    	}
		});
 }
 
 function changebackimg(){
 	$.ajax({
 		type:"get",
 		url:rootPath+"/backTime",
 		async:true,
 		success:function(result){
 			if (result=='2018-01-20') {
 				$("body").attr('style','background-image: url(img/q.png);');
 			}else if(result=='2018-01-21'){
 				$("body").attr('style','background-image: url(img/w.png);');
 			}else if(result=='2018-01-22'){
 				$("body").attr('style','background-image: url(img/e.png);');
 			}else if(result=='2018-01-23'){
 				$("body").attr('style','background-image: url(img/r.png);');
 			}else if(result=='2018-01-24'){
 				$("body").attr('style','background-image: url(img/t.png);');
 			}else if(result=='2018-01-25'){
 				$("body").attr('style','background-image: url(img/y.png);');
 			}else if(result=='2018-01-26'){
 				$("body").attr('style','background-image: url(img/u.png);');
 			}else if(result=='2018-01-27'){
 				$("body").attr('style','background-image: url(img/i.png);');
 			}else if(result=='2018-01-28'){
 				$("body").attr('style','background-image: url(img/o.png);');
 			}else if(result=='2018-01-29'){
 				$("body").attr('style','background-image: url(img/p.png);');
 			}else if(result=='2018-01-30'){
 				$("body").attr('style','background-image: url(img/a.png);');
 			}else if(result=='2018-01-31'){
 				$("body").attr('style','background-image: url(img/s.png);');
 			}else if(result=='2018-01-1'){
 				$("body").attr('style','background-image: url(img/d.png);');
 			}else if(result=='2018-01-2'){
 				$("body").attr('style','background-image: url(img/f.png);');
 			}
 		}
 	});
 }
 
function fmtDate(obj){ 

var date = new Date(obj);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d +' '+h+':'+minute+':'+second;

};